import 'package:city_pickers/city_pickers.dart';
import 'package:city_pickers/modal/result.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yp/helper.dart';
import 'package:yp/widgets/button_widget.dart';
import 'package:yp/widgets/select_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:kzcity_picker/kzcity_picker.dart';
import 'package:yp/config/config.dart';
import 'package:yp/pages/address_update/widgets/text_input.dart';
import 'logic.dart';
import 'state.dart';


class OrderModifyAddressPage extends StatelessWidget {
  final Order_modify_addressLogic logic = Get.put(Order_modify_addressLogic());
  final Order_modify_addressState state = Get.find<Order_modify_addressLogic>().state;


  @override
  Widget build(BuildContext context) {
    // state.addressId = Get.arguments["adr_num_id"].toString();
    print(">>>>>>>>>>>${Get.arguments}");
    return Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          backgroundColor: Config.mainColor,
          brightness: Brightness.light,
          iconTheme: IconThemeData(color: Colors.white),
          title: Text(
            "修改地址",
            style: TextStyle(color: Colors.white, fontSize: 32.sp),
          ),
          centerTitle: true,
          elevation: 0,
        ),
        body:GetBuilder<Order_modify_addressLogic>(
            builder: (logic) {
              return Column(
                children: [
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        // 收货人
                        TextInputWidget(
                          title: "收货人",
                          hintText: "5399",
                          controller:state.controller1,
                        ),

                        // 手机号
                        TextInputWidget(
                          title: "手机号",
                          hintText: "请输入手机号",
                          controller: state.controller2,
                        ),

                        // 所在地区
                        TextInputWidget(
                          title: "所在地区",
                          suffixWidget: GestureDetector(
                            onTap: () {
                              // _clickEventFunc(context);
                            },
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  state?.controller3?.text??'',
                                  style: TextStyle(
                                    fontSize: 28.sp,
                                    color: Colors.grey,
                                  ),
                                ),
                                Icon(
                                  Icons.arrow_forward_ios_rounded,
                                  color: Color(0xffcccccc),
                                  size: 14,
                                )
                              ],
                            ),
                          ),
                        ),
                        // 详细地址
                        // TextInputWidget(
                        //   title: "详细地址",
                        //   hintText: "请输入详细地址",
                        //   controller: state.controller4,
                        // ),
                        Padding(
                          padding: EdgeInsets.symmetric(horizontal: 20.w),
                          child: Container(
                            padding: EdgeInsets.symmetric(
                              vertical: 32.w,
                            ),
                            decoration: BoxDecoration(
                              border: Border(
                                bottom: BorderSide(
                                  color: Color(0xfff0f0f0),
                                ),
                              ),
                            ),
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              mainAxisAlignment: MainAxisAlignment.start,
                              children: [
                                Container(
                                  width: 180.w,
                                  child: Text(
                                    "详细地址",
                                    style: TextStyle(
                                     color: Color(0xff666666),
                                      fontSize: 28.sp,
                                    ),
                                  ),
                                ),
                                Container(
                                 width: 520.w,
                                  child: TextField(
                                    controller: state.controller4,
                                    enabled: true,
                                    textAlignVertical: TextAlignVertical.center,
                                    textAlign: TextAlign.start,
                                    decoration: InputDecoration(
                                      isDense: true,
                                      contentPadding: EdgeInsets.all(0),
                                      hintText: "请输入详细地址",
                                      hintStyle: TextStyle(
                                        fontSize: 28.sp,
                                        color: Color(0xffcccccc),
                                      ),
                                      border: InputBorder.none,
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  Container(
                    color: Colors.white,
                    padding: EdgeInsets.symmetric(vertical: 30.w,horizontal:46.w,),
                    child:GestureDetector(
                      onTap: () {
                        logic.updateAdress();
                      },
                      child:Padding(
                        padding: EdgeInsets.symmetric(
                          horizontal: 20.w,
                        ),
                        child: ButtonWidget(title: "确定"),
                      ),
                    ),
                  ),
                ],
              );
            })

    );
  }

  // Result resultArr = new Result();
  // void _clickEventFunc(context) async {
  //   final res = await KzcityPicker.showPicker(
  //     context,
  //     datas: state.addressList,
  //   );
  //   if (res != null) { // 刷新
  //     logic.selectCity(res);
  //   }
  // }
}